# Appium_Python/pages/LoginPage.py
from .BasePage import BasePage
from appium.webdriver.common.appiumby import AppiumBy


class LoginPage(BasePage):
    # 元素定位
    AGREE_BUTTON = (AppiumBy.ID, 'com.tal.kaoyan:id/tip_commit')
    KNOW_BUTTON = (AppiumBy.ID, 'com.tal.kaoyan:id/tv_ok')
    PASSWORD_LOGIN_BUTTON = (AppiumBy.ID, 'com.tal.kaoyan:id/loginRegistorcodeAndPassword')
    PHONE_INPUT = (AppiumBy.ID, 'com.tal.kaoyan:id/loginEmailEdittext')
    PASSWORD_INPUT = (AppiumBy.ID, 'com.tal.kaoyan:id/loginPasswordEdittext')
    AGREE_CHECKBOX = (AppiumBy.ID, 'com.tal.kaoyan:id/loginTreatyCheckboxPassword')
    LOGIN_BUTTON = (AppiumBy.ID, 'com.tal.kaoyan:id/loginLoginBtn')
    SKIP_BUTTON = (AppiumBy.ID, 'com.tal.kaoyan:id/kylogin_perfect_tag_jump_button')
    FRIST_ELEMENT = (AppiumBy.ID, 'com.tal.kaoyan:id/im_indicator')


    def login(self,username,password):
        self.click(*self.AGREE_BUTTON)
        self.click(*self.KNOW_BUTTON)
        self.click(*self.PASSWORD_LOGIN_BUTTON)
        self.send_keys(*self.PHONE_INPUT,username)
        self.send_keys(*self.PASSWORD_INPUT,password)
        self.click(*self.AGREE_CHECKBOX)
        self.click(*self.LOGIN_BUTTON)
        # self.click(*self.SKIP_BUTTON)

    def get_text_true(self):
        return self.get_text(*self.SKIP_BUTTON)



    # def click_agree_button(self):
    #     self.click_agree()
    #
    # def click_agree(self):
    #     self.click(*self.AGREE_BUTTON)
    #
    # def click_know(self):
    #     self.click(*self.KNOW_BUTTON)
    #
    # def click_password_login(self):
    #     self.click(*self.PASSWORD_LOGIN_BUTTON)
    #
    # def input_phone(self, text):
    #     self.send_keys(*self.PHONE_INPUT, text)
    #
    # def input_password(self, text):
    #     self.send_keys(*self.PASSWORD_INPUT, text)
    #
    # def click_agree_checkbox(self):
    #     self.click(*self.AGREE_CHECKBOX)
    #
    # def click_login(self):
    #     self.click(*self.LOGIN_BUTTON)